﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DynaBoard
{

    public class UnixTime
    {
        private static readonly DateTime unixEpoch =
            new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

        public readonly double Milliseconds;

        public UnixTime(DateTime dateTime)
        {
            if (dateTime == null)
            {
                throw new ArgumentNullException("dateTime");
            }

            if (dateTime.Kind == DateTimeKind.Local)
            {
                throw new ArgumentException("Must be in UTC.", "dateTime");
            }

            this.Milliseconds =
                new TimeSpan(dateTime.Ticks - UnixTime.unixEpoch.Ticks).TotalMilliseconds;
        }

    }

}
